﻿using System;
using System.Threading;
using Domain;
using Domain.Entity;
using Spider.Ants;
using Spider.Spiders;

namespace Spider.Service
{
    public static partial class AntService
    {
        /// <summary>
        /// 命令蚂蚁队长开始工作
        /// </summary>
        /// <returns></returns>
        public static bool CommandAntCaptainToWork()
        {
            try
            {
                Thread th = new Thread(AntCaptain.GetInstance().StartToWork);
                th.Start();
                return true;
            }
            catch (Exception ex)
            {
                CustomsLog.WriteExceptionErrorLog("命令蚂蚁队长开始工作出错", ex);
                return false;
            }
                    
        }
        /// <summary>
        /// 命令蚂蚁队长停止工作
        /// </summary>
        /// <returns></returns>
        public static bool CommandAntCaptainStopToWork(string reason = "")
        {
            try
            {
                AntCaptain.GetInstance().StopToWork(reason);
                return true;
            }
            catch (Exception ex)
            {
                CustomsLog.WriteExceptionErrorLog("命令蚂蚁队长停止工作出错", ex);
                return false;
            }

        }

    }
}
